package wsz.provider2;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScans;
import wsz.rpc.provider.server.RpcServer;

@ComponentScans(value = {@ComponentScan("wsz.rpc.provider")})
@SpringBootApplication
public class Provider2Application implements CommandLineRunner {

    public static void main(String[] args) {
        SpringApplication.run(Provider2Application.class, args);
    }

    @Autowired
    private RpcServer rpcServer;

    @Value("${common.host}")
    private String host;

    @Value("${common.port}")
    private int port;

    @Override
    public void run(String... args) throws Exception {
        new Thread(() -> {
            rpcServer.startServer(host, port);
        }).start();
    }
}
